<template>
  <view class="container">
    <view class="data-list user-list">
	  <view class="user-item" v-for="(item, index) in list" :key="index">
		  <view class="dis-flex">
	      <!-- 客户图片 -->
	      <view class="user-item_left">
	        <image class="image" :src="item.avatar_url"></image>
	      </view>
	      <view class="user-item_right">
	        <!-- 客户名称 -->
	        <view class="user-name twolist-hidden">
	          <text>{{ item.nick_name }}</text>
	        </view>
	        <!-- 客户电话 -->
	        <view class="user-name twolist-hidden">
	          <text>{{ item.mobile }}</text>
	        </view>
	        <!-- 客户积分 -->
	        <view class="user-name twolist-hidden">
	          <text>积分：{{ item.points }}</text>
	        </view>
	      </view>
	      </view>
		  <view class="line"></view>
		  <view class="item-option">
		    <view class="_left">
		    </view>
		    <view class="_right">
		      <view class="events">
		        <view class="event-item" @click="handlePet(item.user_id)">
		          <text class="title">客户宠物</text>
		        </view>
		      </view>
		    </view>
		  </view>
	  </view>
    </view>
    <empty v-if="!list.length" :isLoading="isLoading" tips="亲，暂无数据" />
  </view>
</template>

<script>
  import * as UserApi from '@/apishop/user/user'
  import Empty from '@/components/empty'

  export default {
    components: {
      Empty
    },
    data() {
      return {
        //当前页面参数
        options: {},
        // 正在加载
        isLoading: true,
        // 收货地址列表
        list: [],
      }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      // 当前页面参数
      this.options = options
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
      // 获取页面数据
      this.getPageData()
    },

    methods: {

      // 获取页面数据
      getPageData() {
        const app = this
        app.isLoading = true
        app.getDataList()
      },

      // 获取数据列表
      getDataList() {
        const app = this
        return new Promise((resolve, reject) => {
          UserApi.list(app.options)
            .then(result => {
              app.list = result.data.list.data
              resolve(result)
            })
            .catch(reject)
        })
      },

      // 列表排序把默认收货地址放到最前
      onReorder() {
        const app = this
        app.list()
      },
	  
      handlePet(userId) {
		console.log(userId)
        this.$navTo('pages/shop/pet/index', { userId })
      },
  
    }
  }
</script>

<style lang="scss" scoped>
  // 客户列表
  .user-list {
    padding: 4rpx;
    box-sizing: border-box;
  }

  .item-option {
    display: flex;
    justify-content: space-between;
    height: 48rpx;

    // 操作
    .events {
      display: flex;
      align-items: center;
      line-height: 48rpx;

      .event-item {
        font-size: 28rpx;
        margin-right: 22rpx;
        color: #4c4c4c;

        &:last-child {
          margin-right: 0;
        }

        .title {
          margin-left: 8rpx;
        }
      }
    }

  }


  // 底部操作栏
  .footer-fixed {
    position: fixed;
    bottom: var(--window-bottom);
    left: 0;
    right: 0;
    height: 96rpx;
    z-index: 11;
    box-shadow: 0 -4rpx 40rpx 0 rgba(144, 52, 52, 0.1);
    background: #fff;

    .btn-wrapper {
      height: 100%;
      display: flex;
      align-items: center;
      padding: 0 20rpx;
    }

    .btn-item {
      flex: 1;
      font-size: 28rpx;
      height: 72rpx;
      line-height: 72rpx;
      text-align: center;
      color: #fff;
      border-radius: 50rpx;
    }

    .btn-item-main {
      background: linear-gradient(to right, #f9211c, #ff6335);
    }

  }


  // 商品列表
  .user-list {
    padding: 4rpx;
    box-sizing: border-box;
  }
	
  .user-item {
    width: 100%;
    height: 300rpx;
    margin-bottom: 12rpx;
    padding: 20rpx;
    box-sizing: border-box;
    background: #fff;
    line-height: 1.6;
  
    &:last-child {
      margin-bottom: 0;
    }
  }
  
  .user-item_left {
    display: flex;
    width: 200rpx;
    background: #fff;
    align-items: center;
  
    .image {
      display: block;
      width: 140rpx;
      height: 140rpx;
    }
  }
  
  .user-item_right {
    position: relative;
    // width: 450rpx;
    flex: 1;
  
    .user-name {
      margin-top: 10rpx;
      height: 64rpx;
      line-height: 1.3;
      white-space: normal;
      color: #484848;
      font-size: 26rpx;
    }
  }
  
  
  .item-option {
    display: flex;
    justify-content: space-between;
    height: 48rpx;
  
    // 单选框
    .item-radio {
      font-size: 28rpx;
  
      .radio {
        vertical-align: middle;
        transform: scale(0.76)
      }
  
      .text {
        vertical-align: middle;
      }
    }
  
    // 操作
    .events {
      display: flex;
      align-items: center;
      line-height: 48rpx;
  
      .event-item {
        font-size: 28rpx;
        margin-right: 22rpx;
        color: #4c4c4c;
  
        &:last-child {
          margin-right: 0;
        }
  
        .title {
          margin-left: 8rpx;
        }
      }
    }
  
  }
  
</style>
